grammar Acd;
options {
language=Java;
output=AST;
}
tokens
{
	DQ='"';
	COLON=':';
	BRACKETLEFT='[';
	BRACKETRIGHT=']';
	PARAMETER;
	SECTION;
	ATTRIBUTE;
	PROGRAM;
}

@header {
package net.bioteam.appweb.acd;
}
@lexer::header {
package net.bioteam.appweb.acd;
}
@members {
	protected void mismatch(IntStream input, int ttype, BitSet follow)
	throws RecognitionException
	{
		throw new MismatchedTokenException(ttype, input);
	}
	public Object recoverFromMismatchedSet(IntStream input,
		RecognitionException e,
		BitSet follow)
	throws RecognitionException
	{
		throw e;
	}
}
// Alter code generation so catch-clauses get replace with
// this action.
@rulecatch {
catch (RecognitionException e11) {
	throw e11;
}
}

program : programcontent*->^(PROGRAM programcontent*);

programcontent:parameter^|section^;

	
section : s='section' COLON e=ID BRACKETLEFT attribute* BRACKETRIGHT sectioncontent* 'endsection' COLON e1=ID
	->^(SECTION[$s] $e attribute* sectioncontent* );

sectioncontent:parameter^ |section^;

parameter : t=ID COLON n=ID BRACKETLEFT attribute* BRACKETRIGHT 
	->^(PARAMETER[$t, "parameter"] $t $n attribute*);
attribute : n=ID COLON ATTRVALUE? ->^(ATTRIBUTE[$n, "attribute"] ID ATTRVALUE?);


ID :LETTER (LETTER | '-')*;
WS : ( '\t' | ' ' |'\r' |'\n')+ 	{ skip(); } ;
ATTRVALUE
    : '"' .* '"'
    ;
LINE_COMMENT
    : '#' ~('\n'|'\r')* '\r'? '\n'
    {   
       
            skip();
    }
    ;
//only emma.acd have variable, does not support variable in GUI
VARIABLE: 'variable:' ~('\n'|'\r')* '\r'? '\n' { skip();};
fragment 
LETTER :'a'..'z'|'A'..'Z'|'0'..'9'|'_';


    
